Background

The Office of Spill Prevention and Response (OSPR) incident Tracking database provides data on the occurrence and location of marine and inland oil spills. An incident is classified as an oil spill if there is discharge or there is potential for discharge of deletious materials.

Data is provided by Oil Spill Incident Tracking [ds394]. (n.d.). Retrieved February 17, 2021, from https://gis.data.ca.gov/datasets/7464e3d6f4924b50ad06e5a553d71086_0/data

Initial Data Wrangling

# reading in the county data
ca_counties <- read_sf(here("ca_counties"), layer = "CA_Counties_TIGER2016") %>% 
  clean_names() %>% 
  select(name)

# st_crs(ca_counties)

oil_data <- read_sf(here("oil_data"), layer = "Oil_Spill_Incident_Tracking_%5Bds394%5D") %>% 
  clean_names()

# st_crs(oil_data)

# making sure the two data sets are set to the same crs
ca_counties <- st_transform(ca_counties, st_crs(oil_data))

Setting up the Interactive Map

#putting map in interactive viewing mode
tmap_mode("view")
## tmap mode set to interactive viewing

Creating the Interactive Map

#making exploraory interactive map that shows location of oil spills in california
tm_shape(oil_data)+
  tm_dots(aes(color = "skyblue"), alpha = 0.4)

Chloropleth Map

Setting up for the Chloropleth Map displaying counts of 2008 oil spills in each CA County.
#need to find count of oil spills in each CA county. 
# Step 1- join te data sets (since we already set the coordinate systems to match)

oil_county <- ca_counties %>% 
  st_join(oil_data)


#step 2: getting the counts
oil_counts <- oil_county %>% 
  count(name)
Creating the Chloropleth
# making the chloropleth

ggplot(data = oil_counts) +
  geom_sf(aes(fill = n), color = "white", size = 0.1) +
  scale_fill_gradientn(colors = c("lightblue", "blue", "navyblue")) +
  theme_minimal()+
  labs( fill = "Number of Oil Spills")
Figure 2.0: Distribution of Oil Spills that occured in 2008 by county. As color gradient darkens, the number of oil spills increases per county

Figure 2.0: Distribution of Oil Spills that occured in 2008 by county. As color gradient darkens, the number of oil spills increases per county